﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;

public partial class Resource_sharing : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (Session["se1"] == null)
        {
            Panel2.Visible = false;
            Panel1.Visible = true;
        }
        else
        {
            Panel1.Visible = false;
            Panel2.Visible = true;
            loginname.Text = Session["se1"].ToString();
        }
    }
    protected void tijiao_Click(object sender, EventArgs e)
    {
        string name = TextBox1.Text.Trim();
        string pwd = TextBox2.Text.Trim();
        Xqsys.MODEL.Users user = new Xqsys.MODEL.Users();
        user.Username = name;
        if (new Xqsys.DAL.Users().ExistUserName(name))
        {
            DataSet ds = new Xqsys.BLL.Users().Login(user);
            string pwd1 = ds.Tables[0].Rows[0]["password"].ToString();
            if (pwd == pwd1)
            {
                Session["se1"] = ds.Tables[0].Rows[0]["userName"];
                Session["userID"] = ds.Tables[0].Rows[0]["userID"];
                Session["Role"] = ds.Tables[0].Rows[0]["Role"];
                Response.Redirect("~/index.aspx");
            }
            else
            {
                lit.Text = "<script>alert('密码或用户名错误');</script>";
            }
        }
        else
        {
            lit.Text = "<script>alert('密码或用户名错误!');</script>";
        }
    }
    protected void zhuxiao_Click(object sender, EventArgs e)
    {
        Session.Clear();
        Panel1.Visible = true;
        Panel2.Visible = false;
    }
}